﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Net.Sockets;
using System.IO;


//TODO: Gør færdig

namespace Kravl
{
    public class HttpTcpClient
    {
        public HttpTcpClient()
        {
        }

        public void GetWebPageTcp(Uri httpUrl, ref System.Windows.Forms.TextBox t)
        {
            int port = 80;
            String inputhostname = httpUrl.ToString();
            String hostname = ExtractDomainNameFromURL(inputhostname);
            TcpClient client = new TcpClient(hostname, port);
            NetworkStream stream = client.GetStream();

            stream.Close();
            client.Close();
        }

        public static string ExtractDomainNameFromURL(string Url)
        {
            if (Url.Contains(@"://"))
                Url = Url.Split(new string[] { "://" }, 2, StringSplitOptions.None)[1];
            return Url.Split('/')[0];
        }

        //Kirsten!
        //public string kirsten()
        //{
        //    String str = "GET " + links[0].Page + " HTTP/1.1" + EOL + "Host: " + links[0].Host + EOL;
        //    str += "User-Agent: Crawler)" + EOL;
        //    str += "Accept: 		text/xml,application/xml,application/xhtml+xml,text/html;text/plain" + EOL;
        //    str += "Connection: close" + EOL;
        //    str += EOL;
        //    str += EOL;
        //    return str;
        //}
    }
}
